-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Implement unstable trait impl #140399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement unstable trait impl #140399
Conversation
d01f12a
to
9e139e1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
486d3d3
to
02f780f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
567ec89
to
80fd239
Compare
☔ The latest upstream changes (presumably #142299) made this pull request unmergeable. Please resolve the merge conflicts. |
850e3e1
to
27d9e21
Compare
2865cd0
to
aa746cb
Compare
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Implement unstable trait impl This PR allows marking impls of stable trait with stable type as unstable. ## Approach In std/core, an impl can be marked as unstable by annotating it with ``#[unstable_feature_bound(feat_name)]``. This will add a ``ClauseKind::Unstable_Feature(feat_name)`` to the list of predicates in ``predicates_of`` . When an unstable impl's function is called, we will first iterate through all the goals in ``param_env`` to check if there is any ``ClauseKind::UnstableFeature(feat_name)`` in ``param_env``. The existence of ``ClauseKind::Unstable_Feature(feat_name)`` in ``param_env`` means an``#[unstable_feature_bound(feat_name)]`` is present at the call site of the function, so we allow the check to succeed in this case. If ``ClauseKind::UnstableFeature(feat_name)`` does not exist in ``param_env``, we will still allow the check to succeed for either of the cases below: 1. The feature is enabled through ``#[feature(feat_name)]`` outside of std / core. 2. We are in codegen because we may be monomorphizing a body from an upstream crate which had an unstable feature enabled that the downstream crate do not. For the rest of the case, it will fail with ambiguity. ## Limitation In this PR, we do not support: 1. using items that need ``#[unstable_feature_bound]`` within stable APIs 2. annotate main function with ``#[unstable_feature_bound]`` 3. annotate ``#[unstable_feature_bound]`` on items other than free function and impl ## Acknowledgement The design and mentoring are done by `@BoxyUwU`
This comment has been minimized.
This comment has been minimized.
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Implement unstable trait impl This PR allows marking impls of stable trait with stable type as unstable. ## Approach In std/core, an impl can be marked as unstable by annotating it with ``#[unstable_feature_bound(feat_name)]``. This will add a ``ClauseKind::Unstable_Feature(feat_name)`` to the list of predicates in ``predicates_of`` . When an unstable impl's function is called, we will first iterate through all the goals in ``param_env`` to check if there is any ``ClauseKind::UnstableFeature(feat_name)`` in ``param_env``. The existence of ``ClauseKind::Unstable_Feature(feat_name)`` in ``param_env`` means an``#[unstable_feature_bound(feat_name)]`` is present at the call site of the function, so we allow the check to succeed in this case. If ``ClauseKind::UnstableFeature(feat_name)`` does not exist in ``param_env``, we will still allow the check to succeed for either of the cases below: 1. The feature is enabled through ``#[feature(feat_name)]`` outside of std / core. 2. We are in codegen because we may be monomorphizing a body from an upstream crate which had an unstable feature enabled that the downstream crate do not. For the rest of the case, it will fail with ambiguity. ## Limitation In this PR, we do not support: 1. using items that need ``#[unstable_feature_bound]`` within stable APIs 2. annotate main function with ``#[unstable_feature_bound]`` 3. annotate ``#[unstable_feature_bound]`` on items other than free function and impl ## Acknowledgement The design and mentoring are done by `@BoxyUwU`
This comment has been minimized.
This comment has been minimized.
I should have made the CI green first... will request for perf run afterward. |
dc8f28f
to
637b820
Compare
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (93970f9): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -4.9%, secondary 2.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.2%, secondary 3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 463.69s -> 465.733s (0.44%) |
The only difference between the latest commit and the one being used for perf is comment. Hi @compiler-errors, I think you might be interested to see the perf result. |
☔ The latest upstream changes (presumably #143934) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR allows marking impls of stable trait with stable type as unstable.
Approach
In std/core, an impl can be marked as unstable by annotating it with
#[unstable_feature_bound(feat_name)]
. This will add aClauseKind::Unstable_Feature(feat_name)
to the list of predicates inpredicates_of
.When an unstable impl's function is called, we will first iterate through all the goals in
param_env
to check if there is anyClauseKind::UnstableFeature(feat_name)
inparam_env
.The existence of
ClauseKind::Unstable_Feature(feat_name)
inparam_env
means an#[unstable_feature_bound(feat_name)]
is present at the call site of the function, so we allow the check to succeed in this case.If
ClauseKind::UnstableFeature(feat_name)
does not exist inparam_env
, we will still allow the check to succeed for either of the cases below:#[feature(feat_name)]
outside of std / core.For the rest of the case, it will fail with ambiguity.
Limitation
In this PR, we do not support:
#[unstable_feature_bound]
within stable APIs#[unstable_feature_bound]
#[unstable_feature_bound]
on items other than free function and implAcknowledgement
The design and mentoring are done by @BoxyUwU